package ru.tulupov.producerconsumerpattern;

import java.util.Random;

public enum ToyType {
	DOLL() {
		{
			probability = 0.5;
		}
	},
	CAR() {
		{
			probability = 0.25;
		}
	},
	KNIFE() {
		{
			probability = 0.1;
		}
	};

	protected double probability;

	public void playWithToy() {
		Random random = new Random();
		double number = random.nextDouble();

		if (number < probability) {
			throw new ToyBrokenException();
		}
	}
}